package com.kaigejava.juc.concurrentcontainers;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author kaigejava
 * 证明arrayList在多线程并发情况下是线程不安全的
 */
public class ListDemo1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        List<String> vetory = new Vector<>();
        List<String> list2 = Collections.synchronizedList(new ArrayList<>());
        List<String> list3 = new  CopyOnWriteArrayList<>();
        for(int i = 0;i<30;i++){
            new Thread(()->{
                list.add(UUID.randomUUID().toString().replace("-",""));
                System.out.println(list);
            },"线程"+(i+1)).start();
        }
    }
}
